package com.nowcoder.code.lcof;

import com.algorithm.model.ListNode;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class JZ23 {

    public static void main(String[] args) {

    }

    public ListNode EntryNodeOfLoop(ListNode pHead) {
        Set<ListNode> set = new HashSet<>();
        while (pHead != null) {
            if (set.contains(pHead)) {
                return pHead;
            }
            set.add(pHead);
            pHead = pHead.next;
        }
        return null;
    }

}
